const util = require('../../utils/util.js');

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    open: false,
    close: true,
    animPlus: {},//旋转动画
    animMin: {},
    animList: {},
    animLayer: {}
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //点击弹出
    plus: function () {
      this.popp();
      this.setData({
        open: true,
        close: false
      })

    },
    //点击收起
    min: function () {
      this.takeback();
      this.setData({
        close: false,
        open: false
      })

    },
    animdefault: function () {
      // wx.reLaunch({
      //   url: '../index/index'
      // })
      util.navigateTo('../index/index')
    },
    animCate: function () {
      // wx.reLaunch({
      //   url: '../category/category'
      // })
      util.navigateTo('../category/category')
    },
    animCart: function () {
      // wx.reLaunch({
      //   url: '../cart/cart'
      // })
      util.navigateTo('../cart/cart')
    },
    animHome: function () {
      // wx.reLaunch({
      //   url: '../myhome/myhome'
      // })
      util.navigateTo('../myhome/myhome')
    },
    //弹出动画
    popp: function () {
      //plus顺时针旋转
      var animationPlus = wx.createAnimation({
        duration: 500,
        timingFunction: 'ease-out'
      })
      var animationMin = wx.createAnimation({
        duration: 500,
        timingFunction: 'ease-out'
      })
      var animationList = wx.createAnimation({
        duration: 500,
        timingFunction: 'ease-out'
      })
      var animationLayer = wx.createAnimation({
        duration: 10,
        timingFunction: 'ease-out'
      })
      animationPlus.translate(0, 0).opacity(0).step();
      animationMin.translate(-200, 0).opacity(1).step();
      animationList.translate(-200, 0).opacity(1).step();
      animationLayer.width(wx.getSystemInfoSync().windowWidth).opacity(1).step();
      this.setData({
        animPlus: animationPlus.export(),
        animMin: animationMin.export(),
        animList: animationList.export(),
        animLayer: animationLayer.export()
      })
    },
    //收回动画
    takeback: function () {
      //plus逆时针旋转
      var animationPlus = wx.createAnimation({
        duration: 500,
        timingFunction: 'ease-out'
      })
      var animationMin = wx.createAnimation({
        duration: 500,
        timingFunction: 'ease-out'
      })
      var animationList = wx.createAnimation({
        duration: 500,
        timingFunction: 'ease-out'
      })
      var animationLayer = wx.createAnimation({
        duration: 10,
        timingFunction: 'ease-out'
      })
      animationPlus.translate(0, 0).opacity(1).step();
      animationMin.translate(0, 0).opacity(0).step();
      animationList.translate(0, 0).opacity(0).step();
      animationLayer.width(0).opacity(0).step();
      this.setData({
        animPlus: animationPlus.export(),
        animMin: animationMin.export(),
        animList: animationList.export(),
        animLayer: animationLayer.export()
      })
    }
  },
  //解决滚动穿透问题
  myCatchTouch: function () {
    return
  }
  
})
